{{extend 'layout.html'}}
<!-- css -->
<style type="text/css">

table, td, th
{
text-align:left;
<!--border: 1px solid black;-->
}
#table_layout
{
width:100%;
}

#table_content
{
width: 300px;
}

</style>
<!-- end css -->
<p id="newhotscore">
{{for s in sorts:}}
[{{=A(s,_href=URL(r=request,args=[category,s,page]))}}]
{{pass}}
{{if page>0:}}[{{=A('prev',_href=URL(r=request,args=[category,sort,page-1]))}}]{{pass}}
{{if page<3 and len(news)>9:}}[{{=A('next',_href=URL(r=request,args=[category,sort,page+1]))}}]{{pass}}
</p>

<br/>
<br/>

<table id="table_layout">
{{count =0}}    
{{for k,item in enumerate(news):}}{{if k==9: break}}
{{count = count + 1}}
{{if k%3 == 0:}}
	<tr>
{{pass}}
		<td valign="top">
<!-- a table cell for story and rating -->
<table id="table_content"><tr>
	<td valign="top">
		<!-- table for Story --->
		<table>
			<tr>
				<td class="article">
				{{if item.url.strip().lower()=='self':}}
				<a>{{=A(item.title,_href=URL(r=request,f='comments',args=[item.id]))}}</a>
				{{else:}}
				<a>{{=A(item.title,_href=URL(r=request,f='read',args=[item.id]))}}</a>
				{{pass}}
				</td>
			</tr>
			<tr>
				<td id= "writer_name">
					{{=item.writer}}
				</td>
			</tr>
			<tr>
				<th>
<!--				{{star_count = 0}}
				{{if item.scoringtime !=0 :}}
					{{star_count=item.score/item.scoringtime}}
				{{pass}}
				{{for i in range(0,star_count,1):}}
				{{=A(IMG(_src=URL(r=request,c='static',f='star.jpg')))}}
				{{pass}}
				{{=item.clicks}}-->
<!--				{{="score : "}}{{=item.score}}{{=" "}}{{=item.scoringtime}}{{="   "}}{{="    view : "}}{{=item.clicks}}{{='k'}}{{=k}}-->
				</th>
			</tr>
			<tr>
				<td><id = "foreword" >
				<!-- in case of displaying foreword {{=item.foreword}}-->			
				{{comment=db(db.comment.news==item.id).select(orderby=~db.comment.score)}}
				{{if len(comment) !=0:}}
					{{=comment[0].body}}
				{{pass}}
				</td>
			</tr>
<!--			<tr><td><i>submitted {{=timesince(item.post_time,now)}} ago by {{=A(item.author_alias,_href=URL(r=request,f='person',args=[item.author]))}}</i>
				</td>
			</tr>-->
			<tr>
				<td><i>
				{{=A('%i comments'%item.comments,_href=URL(r=request,f='comments',args=[item.id]))}} 
					{{=A('report',_href=URL(r=request,f='report',args=[item.id]))}} 
					{{if item.author==session.authorized:}} 
						{{=A('edit',_href=URL(r=request,f='edit_post',args=[item.id]))}} 
						{{=A('delete',_href=URL(r=request,f='delete',args=[item.id]))}} 
					{{pass}}
				</i></td>
			</tr>
		</table>
	</td>
	</tr>
</table>
<!--end a table cell for story and rating-->
		</td>
{{if count%3 == 0:}}
	</tr>
{{pass}}
{{pass}}
</table>